package com.example.springbootmybatisplus.sjms;

import com.example.springbootmybatisplus.model.dto.LoginReq;
import com.example.springbootmybatisplus.model.vo.LoginResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName UserService
 * @Description: TODO
 * @Author: Sunny
 * @Create: 2024-08-18 20:35
 * @Version 1.0
 **/
@Service
public class UserService {
    @Autowired
    private UserLoginFactory factory;

    public LoginResp login(LoginReq loginReq){
        UserGranter granter =
                factory.getGranter(loginReq.getType());
        if(granter == null){
            LoginResp loginResp = new LoginResp();
            loginResp.setSuccess(false);
            return loginResp;
        }
        LoginResp loginResp = granter.login(loginReq);
        return loginResp;
    }
}